package com.tigerhhzz.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author tigerhhzz
 * @Date 2024 10 05 11 38
 **/
@Configuration
public class RabbitMQConfig {

    public static final String SMS_QUEUE = "smsQueue";
    public static final String SMS_EXCHANGE = "smsExchange";
    public static final String SMS_ROUTING_KEY = "smsRoutingKey";

    @Bean
    public Queue smsQueue() {
        return new Queue(SMS_QUEUE);
    }

    @Bean
    public TopicExchange smsExchange() {
        return new TopicExchange(SMS_EXCHANGE);
    }

    @Bean
    public Binding binding(Queue smsQueue, TopicExchange smsExchange) {
        return BindingBuilder.bind(smsQueue).to(smsExchange).with(SMS_ROUTING_KEY);
    }
}
